package io.renren.modules.app.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.pms.entity.ProductAttributeCategoryEntity;
import io.renren.modules.pms.entity.dto.ProductAttributeCateDTO;
import io.renren.modules.pms.service.ProductAttributeCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 *
 *
 * @author LuoShun
 * @email lori6166@163.com
 * @date 2021-12-26 15:54:15
 */
@Api(tags  = "App商品类型接口")
@RestController
@RequestMapping("app/productAttribute/category")
public class AppProductAttributeCategoryController {

    @Autowired
    private ProductAttributeCategoryService productAttributeCategoryService;

    /**
     * 分页获取商品类型列表
     */
    @ApiOperation("分页获取商品类型列表")
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = productAttributeCategoryService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 根据id获取商品类型
     */
    @ApiOperation("根据id获取商品类型")
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		ProductAttributeCategoryEntity productAttributeCategory = productAttributeCategoryService.getById(id);

        return R.ok().put("productAttributeCategory", productAttributeCategory);
    }

    /**
     * 获取所有商品属性分类及其下属性
     */
    @ApiOperation("获取所有商品属性分类及其下属性")
    @GetMapping(value = "/list/withAttr")
    public R getListWithAttr() {
        List<ProductAttributeCateDTO> list = productAttributeCategoryService.getListWithAttr();
        return R.ok().put("data",list);
    }

}
